import asyncio
import random


async def compute(x, y):
    print("Compute %s + %s ..." % (x, y))
    await asyncio.sleep(random.randint(1, 2))
    print('hello world')
    return x + y

async def print_sum(x, y):
    result = await compute(x, y)
    print("%s + %s = %s" % (x, y, result))
    return result

loop = asyncio.get_event_loop()
tasks = [print_sum(1, 2), print_sum(4, 5)]
res = loop.run_until_complete(asyncio.wait(tasks))
print(len(res), type(res))
# for val in res:
#     print(val, type(val))
#     for item in val:
#         print(item, type(item))

print(asyncio.iscoroutinefunction(print_sum)) # True
print(asyncio.iscoroutinefunction(compute)) # True
loop.close()

# Compute 4 + 5 ...
# Compute 1 + 2 ...
# hello world
# 4 + 5 = 9
# hello world
# 1 + 2 = 3
# True
# True
